#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	ll n,l,r;
	cin>>n>>l>>r;
	ll max=0;
	for(ll i=l;i<=r;i++)
	{
		if(max<i%n)
		{
			max=i%n;
		}
	}
	cout<<max;
	return 0;
}
